﻿#include "FITKAbstractAssInstance.h"
#include "FITK_Kernel/FITKCore/FITKDataRepo.h"


namespace Interface
{
    /**
     * @brief Destroy the FITKAbstractAssInstance::FITKAbstractAssInstance object
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-03-29
     */
    FITKAbstractAssInstance::~FITKAbstractAssInstance()
    {
    }

    Interface::FITKModelEnum::AbsModelType FITKAbstractAssInstance::getAbsModelType()
    {
        //获取类型
        return FITKModelEnum::AbsModelType::AssInstance;
    }

    void FITKAbstractAssInstance::setModel(int modelid)
    {
        _modelID = modelid;
    }

    void FITKAbstractAssInstance::setModel(FITKAbstractModel* model)
    {
        //转成id存储
        if (model == nullptr) _modelID = -1;
        _modelID = model->getDataObjectID();
    }

    FITKAbstractModel* FITKAbstractAssInstance::getModel() const
    {
        //从全局仓库查找
        return Core::FITKDataRepo::getInstance()->getTDataByID<FITKAbstractModel>(_modelID);
    }

    int FITKAbstractAssInstance::getModelID() const
    {
        return _modelID;
    }

    FITKComponentManager* FITKAbstractAssInstance::getComponentManager()
    {
        auto m = this-> getModel();
        if (m == nullptr) return nullptr;
        return m->getComponentManager();
    }

    FITKModelEnum::FITKModelDim FITKAbstractAssInstance::getModelDim()
    {
        auto model = this->getModel();
        //返回原始的模型维度
        if (model)
            return model->getModelDim();

        return FITKModelEnum::FITKModelDim::FMDNone;
    }
}


